package com.dgshanger.sanhxiaofeisc.mvp.model

import com.dgshanger.sanhxiaofeisc.common.AppApi
import com.dgshanger.sanhxiaofeisc.entity.ShopDetailsEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.ShopDetailsContract
import com.xx.baseutilslibrary.network.rx.RxHelper
import com.xx.baseutilslibrary.network.rx.XxBaseHttpObserver

/**
 * Created by JacobHHH on 2018/4/18.
 */
class ShopDetailsModel : ShopDetailsContract.Model {

    override fun cancelCollect(shop_id: String?, httpObserver: XxBaseHttpObserver<Any>?) {
        AppApi.Api().cancelCollect(shop_id)
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)
    }

    override fun collectShop(shop_id: String?, httpObserver: XxBaseHttpObserver<Any>?) {
        AppApi.Api().collectShop(shop_id)
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)

    }

    override fun loadData(shop_id: String?, httpObserver: XxBaseHttpObserver<ShopDetailsEntity>?) {
        AppApi.Api().getShopDetailsData(shop_id)
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)
    }
}